/**
 * Promise.done
 */
if (typeof Promise.prototype.done != 'function') {
  Promise.prototype.done = function (onResolved, onRejected) {
    this
      .then(onResolved, onRejected)
      .catch(function (err) {
        setTimeout(() => { throw err }, 0); //抛出一个全局错误
      })
  }
}
/**
 * Promise.finally
 */
if (typeof Promise.prototype.finally != 'function'){
  Promise.prototype.finally = function (callback) {
    'use strict';
    let P = this.constructor;
    return this.then(
      value => P.resolve(callback(value)),
      err => P.resolve(callback(err))
    );
  };
}